<%--
  Created by IntelliJ IDEA.
  User: xiaomi
  Date: 2025/2/7
  Time: 9:39
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>首页</title>
    <script src="https://s3.pstatp.com/cdn/expire-1-M/jquery/3.3.1/jquery.min.js"></script>
    <link rel="stylesheet" type="text/css" href="style.css">
    <style>
        table {
            border-collapse: collapse;
            width: 80%;
            margin: 20px auto;
        }

        table,
        th,
        td {
            border: 1px solid rgb(165, 184, 213);
        }
        th,
        td {
            text-align: center;
            padding: 8px;
        }
        th{
            background: rgb(165, 184, 213);
            color: white;
        }
        button {
            padding: 5px 10px;
            margin: 5px;
            border: none;
            border-radius: 3px;
            background-color: rgb(165, 184, 213);
            color: white;
            cursor: pointer;
        }

        button:hover {
            background-color: rgb(125, 166, 217);
        }

        input[type = "checkbox"] {
            margin-right: 5px;
        }
    </style>
</head>
<body>
<table id="courseTable">
    <tr>
        <th>账号</th>
        <th>姓名</th>
        <th>性别</th>
        <th>类型</th>
    </tr>
</table>
<script>
    $(document).ready(function () {
        var usertype = "用户";
        var url = './user/find/'+usertype;
        // 使用AJAX获取课程信息
        $.ajax({
            url: url,
            type: 'POST',
            dataType: 'json',
            success: function (data) {
                var table = $('#courseTable');
                data.forEach(function (course) {
                    var row = $('<tr></tr>');
                    row.append($('<td></td>').text(course.username));
                    row.append($('<td></td>').text(course.name));
                    row.append($('<td></td>').text(course.gender));
                    row.append($('<td></td>').text(course.usertype));
                    table.append(row);
                });
            },
            error: function () {
                alert('获取用户信息失败');
            }
        });
    });
</script>
</body>
</html>